package com.csun.cmny.provider.controller;

import com.csun.cmny.core.annotation.ValidateAnnotation;
import com.csun.cmny.core.support.BaseController;
import com.csun.cmny.provider.model.domain.OmcCallOutDoctorRecord;
import com.csun.cmny.provider.model.dto.callOutDoctorRecord.CallOutDoctorRecordSaveDto;
import com.csun.cmny.provider.model.dto.callOutDoctorRecord.CallOutDoctorRecordSelectDto;
import com.csun.cmny.provider.model.dto.comments.CommentsSaveDto;
import com.csun.cmny.provider.model.vo.callOutDoctorRecord.CallOutDoctorRecordVo;
import com.csun.cmny.provider.resolver.CmnyMessageSource;
import com.csun.cmny.provider.service.OmcCallOutDoctorRecordService;
import com.csun.cmny.util.wrapper.WrapMapper;
import com.csun.cmny.util.wrapper.Wrapper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.http.MediaType;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

@RestController
@RequestMapping(value = "/callOutDoctorRecord", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class OmcCallOutDoctorRecordController extends BaseController {

    @Resource
    private CmnyMessageSource cmnyMessageSource;

    @Resource
    private OmcCallOutDoctorRecordService callOutDoctorRecordService;

    @ValidateAnnotation
    @ApiOperation(httpMethod = "POST", value = "呼叫医生")
    @RequestMapping(value = "/callDoctor", method = RequestMethod.POST)
    public Wrapper callDoctor(@RequestBody @Valid CallOutDoctorRecordSaveDto callOutDoctorRecordSaveDto, BindingResult br) {



        int result=callOutDoctorRecordService.callDoctor(callOutDoctorRecordSaveDto);


        return WrapMapper.wrap(Wrapper.SUCCESS_CODE,cmnyMessageSource.getMessage("operation.success", null),result);
    }

    @ValidateAnnotation
    @ApiOperation(httpMethod = "POST", value = "查看呼叫医生记录")
    @RequestMapping(value = "/selectCallOutDoctorRecord", method = RequestMethod.POST)
    public Wrapper selectCallOutDoctorRecord(@RequestBody @Valid CallOutDoctorRecordSelectDto callOutDoctorRecordSelectDto, BindingResult br) {


        List<CallOutDoctorRecordVo>list=callOutDoctorRecordService.selectCallOutDoctorRecord(callOutDoctorRecordSelectDto);

        PageInfo<CallOutDoctorRecordVo> pageInfo = new PageInfo<>(list);


        return WrapMapper.wrap(Wrapper.SUCCESS_CODE,cmnyMessageSource.getMessage("operation.success", null),pageInfo);
    }
}
